package com.ljc.api;

import com.ljc.entity.*;
import com.ljc.interfaces.VideoApi;
import com.ljc.mapper.VideoMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@DubboService
public class VideoApiImpl implements VideoApi {
    @Resource
    private VideoMapper videoMapper;

    /**
     * 视频投稿
     */
    @Override
    public Video addVideos(Video video) {
        videoMapper.addVideos(video);
        return video;
    }

    /**
     * 对视频批量添加标签
     */
    @Override
    public void batchAddVideoTags(List<VideoTag> videoTagList) {
        videoMapper.batchAddVideoTags(videoTagList);
    }

    /**
     * 获得视频的分页数
     */
    @Override
    public Integer pageCountVideos(Map<String, Object> params) {
        return videoMapper.pageCountVideos(params);
    }

    /**
     * 查询视频信息
     */
    @Override
    public List<Video> pageListVideos(Map<String, Object> params) {
        return videoMapper.pageListVideos(params);
    }

    /**
     * 根据视频id查询视频
     */
    @Override
    public Video getVideoById(Long videoId) {
        return videoMapper.getVideoById(videoId);
    }

    /**
     * 查询当前视频是否被当前用户点赞过
     */
    @Override
    public VideoLike getVideoLikeByVideoIdAndUserId(Long videoId, Long userId) {
        return videoMapper.getVideoLikeByVideoIdAndUserId(videoId, userId);
    }

    /**
     * 新增一条点赞记录
     */
    @Override
    public void addVideoLike(VideoLike videoLike) {
        videoMapper.addVideoLike(videoLike);
    }

    /**
     * 取消点赞视频
     */
    @Override
    public void deleteVideoLike(Long videoId, Long userId) {
        videoMapper.deleteVideoLike(videoId, userId);
    }

    /**
     * 查询视频点赞数量
     */
    @Override
    public Long getVideoLikes(Long videoId) {
        return videoMapper.getVideoLikes(videoId);
    }

    /**
     * 删除原有视频收藏
     */
    @Override
    public void deleteVideoCollection(Long videoId, Long userId) {
        videoMapper.deleteVideoCollection(videoId, userId);
    }

    /**
     * 添加新的视频收藏
     */
    @Override
    public void addVideoCollection(VideoCollection videoCollection) {
        videoMapper.addVideoCollection(videoCollection);
    }

    /**
     * 查询视频收藏数量
     */
    @Override
    public Long getVideoCollections(Long videoId) {
        return videoMapper.getVideoCollections(videoId);
    }

    /**
     * 根据视频id和用户id查询用户是否点赞过该视频
     */
    @Override
    public VideoCollection getVideoCollectionByVideoIdAndUserId(Long videoId, Long userId) {
        return videoMapper.getVideoCollectionByVideoIdAndUserId(videoId, userId);
    }

    /**
     * 根据视频id和用户id查询该用户对该视频的投币数
     */
    @Override
    public VideoCoin getVideoCoinByVideoIdAndUserId(Long videoId, Long userId) {
        return videoMapper.getVideoCoinByVideoIdAndUserId(videoId, userId);
    }

    /**
     * 新增视频投币
     */
    @Override
    public void addVideoCoin(VideoCoin videoCoin) {
        videoMapper.addVideoCoin(videoCoin);
    }

    /**
     * 更新视频投币
     */
    @Override
    public void updateVideoCoin(VideoCoin videoCoin) {
        videoMapper.updateVideoCoin(videoCoin);
    }

    /**
     * 获取视频投币数
     */
    @Override
    public Long getVideoCoinsAmount(Long videoId) {
        return videoMapper.getVideoCoinsAmount(videoId);
    }

    /**
     * 添加视频评论
     */
    @Override
    public void addVideoComment(VideoComment videoComment) {
        videoMapper.addVideoComment(videoComment);
    }

    /**
     * 查询视频评论的分页数量
     */
    @Override
    public Integer pageCountVideoComments(Map<String, Object> params) {
        return videoMapper.pageCountVideoComments(params);
    }

    /**
     * 分页查询一级视频的评论
     */
    @Override
    public List<VideoComment> pageListVideoComments(Map<String, Object> params) {
        return videoMapper.pageListVideoComments(params);
    }

    /**
     * 根据根评论批量查询视频二级评论
     */
    @Override
    public List<VideoComment> batchGetVideoCommentsByRootIds(List<Long> parentIdList) {
        return videoMapper.batchGetVideoCommentsByRootIds(parentIdList);
    }

    /**
     * 根据视频id获取视频详情
     */
    @Override
    public Video getVideoDetails(Long videoId) {
        return videoMapper.getVideoDetails(videoId);
    }

    /**
     * 获取视频访问记录
     */
    @Override
    public VideoView getVideoView(Map<String, Object> params) {
        return videoMapper.getVideoView(params);
    }

    /**
     * 添加观看记录
     */
    @Override
    public void addVideoView(VideoView videoView) {
        videoMapper.addVideoView(videoView);
    }

    /**
     * 查询视频播放量
     */
    @Override
    public Integer getVideoViewCounts(Long videoId) {
        return videoMapper.getVideoViewCounts(videoId);
    }

    /**
     * 获取所有用户偏好
     */
    @Override
    public List<UserPreference> getAllUserPreference() {
        return videoMapper.getAllUserPreference();
    }

    /**
     * 根据视频id列表批量查询视频
     */
    @Override
    public List<Video> batchGetVideosByIds(List<Long> itemIds) {
        return videoMapper.batchGetVideosByIds(itemIds);
    }

    /**
     * 通过视频id获取视频标签
     */
    @Override
    public List<VideoTag> getVideoTagsByVideoId(Long videoId) {
        return videoMapper.getVideoTagsByVideoId(videoId);
    }

    /**
     * 批量删除视频标签
     */
    @Override
    public void deleteVideoTags(List<Long> tagIdList, Long videoId) {
        videoMapper.deleteVideoTags(tagIdList, videoId);
    }
}
